<template>
	<view>
		<view class="sh-userinfo-box"
		:style="{ background: `url(${bgimgs}) no-repeat center / 100% 100%` }">
			<view style="height:44px"></view>
			<view class="u-flex listbox">
				<text @tap="goBack"
				  class="u-iconfont uicon-arrow-left"
				  style="color: #111;font-size:40rpx;margin-left:34rpx;"
				></text>
				<view class="name">我的积分</view>
			</view>
			<view class="num">{{newincomeMoney}}</view>
			<view class="text">当前积分</view>
		</view>
		<view class="list">
			<view class="list_title">积分明细</view>
			<scroll-view scroll-y="true" enable-back-to-top @scrolltolower="loadMore" class="scroll-box">
				<view class="list_box" v-for="item in walletLog">
					<view class="list_box_lt">
						<view class="name">{{item.type_name}}</view>
						<view class="time">{{ $u.timeFormat(item.createtime, 'yyyy-mm-dd hh:MM') }}</view>
					</view>
					<view class="list_box_rt">{{item.wallet>0?"+":''}}{{ item.wallet }}积分</view>
				</view>
				
				<!-- <shopro-empty v-if="isEmpty" :image="$IMG_URL + '/imgs/empty/empty_groupon.png'"
					tipText="暂无积分~"></shopro-empty> -->
				
				<u-loadmore v-show="isEmpty" height="80rpx" :status="loadStatus" icon-type="flower"
					color="#ccc" />
			</scroll-view>
		</view>
	</view>
</template>

<script>
	// 获取系统状态栏的高度
	let systemInfo = uni.getSystemInfoSync();
	export default {
		data() {
			return {
				statusBarHeight: systemInfo.statusBarHeight,
				navBackground: {
					background: 'none'
				},
				walletLog:[],
				bgimgs:'https://xcx.yimiaomaoshe.com/images/bg_02.png',
				isEmpty:false,
				loadStatus: 'loadmore',//loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
				currentPage:1,
				lastPage:1,
				stateCurrent: 'all',
				expendMoney:'',
				incomeMoney:'',
				newincomeMoney:''
			}
		},
		onLoad() {
			this.getWalletLog()
		},
		methods: {
			goBack() {
				uni.navigateBack();
			},
			// 加载更多
			loadMore() {
				console.log(111)
				// if (this.currentPage < this.lastPage) {
				// 	this.currentPage += 1;
				// 	// this.getOrderList();
				// }
				if (this.currentPage < this.lastPage) {
					this.currentPage += 1;
					this.getWalletLog();
				}
			},
			// 钱包明细
			getWalletLog() {
				let that = this;
				that.loadStatus = 'loading';
				that.$http('money.walletLog', {
					wallet_type: 'money',
					status: that.stateCurrent,
					// date: that.propsDate,
					// page: that.currentPage
				}).then(res => {
					if (res.code === 1) {
						that.walletLog = [...that.walletLog, ...res.data.wallet_logs.data];
						that.incomeMoney = res.data.income;
						that.expendMoney = Math.abs(res.data.expend);
						that.newincomeMoney= (that.incomeMoney*1000-that.expendMoney*1000)/1000
						that.isEmpty = !that.walletLog.length;
						that.lastPage = res.data.wallet_logs.last_page;
						that.loadStatus = that.currentPage < res.data.wallet_logs.last_page ? 'loadmore' :
							'nomore';
					}
				});
			}
		}
	}
</script>

<style lang="scss">
.sh-userinfo-box{
	position: relative;
	height: 544rpx;
	.listbox{
		height: 90rpx;
		align-items: center;
		.name{margin-left:256rpx;}
	}
	.num{
		font-size: 52rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #111111;
		text-align: center;
		margin-top:70rpx;
	}
	.text{
		font-size: 30rpx;
		font-family: SourceHanSansCN-Regular, SourceHanSansCN;
		font-weight: 400;
		color: rgba(17,17,17,0.72);
		text-align: center;
		margin-top:10rpx;
	}
	
}
	.list{
		position: relative;
		// box-sizing: border-box;
		padding:40rpx 28rpx;
		width: 702rpx;
		height: 70vh;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin:0 auto;
		margin-top:-150rpx;
		z-index: 99;
		overflow: hidden;
		.list_title{
			font-size: 36rpx;
			font-family: SourceHanSansCN-Medium, SourceHanSansCN;
			font-weight: 600;
			color: #111111;
			margin-bottom: 10rpx;
		}
		.list_box{
			height: 146rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 2rpx solid rgba(228,228,228,0.42);
			.list_box_lt{
				.name{
					font-size: 30rpx;
					color: #111111;
				}
				.time{
					font-size: 24rpx;
					color: #999999;
					margin-top:20rpx;
				}
			}
			.list_box_rt{
				font-size: 30rpx;
				color: #111111;
			}
			.list_box_rt2{
				color:#E60000;
			}
		}
	}
</style>
